#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back

using namespace std;

typedef pair < int , int > pii;
typedef vector < int > vec;
typedef vector < pii > veg;
typedef long long ll;
typedef double db;

int read() {
    int x = 0; bool f = 0; char ch = getchar(); while(!isdigit(ch)) f |= ch =='-',ch = getchar();
    while(isdigit(ch)) x = x * 10 + (ch ^ 48),ch = getchar(); return f ? -x : x;
}

const int N = 5e4 + 10;

int mu[N],pri[N],pnum,n,c[N];
ll f[N];
bool v[N];
ll ans;

void shai(int l) {
    mu[1] = 1;
    for(int i = 2;i <= l;i++) {
	if(!v[i]) pri[++pnum] = i,mu[i] = -1;
	for(int j = 1;j <= pnum && pri[j] * i <= l;j++) {
	    v[pri[j] * i] = true; if(i % pri[j] == 0) break; mu[pri[j] * i] = -mu[i];
	}
    }
    for(int i = 1;i <= l;i++) if(mu[i])
	for(int j = i;j <= l;j += i) f[j] += 1ll * mu[i] * i;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("1.in","r",stdin);
#endif
    shai(50000); n = in; for(int i = 1;i <= n;i++) c[in]++;
    for(int T = 1;T <= 50000;T++) {
	ll res = 0; 
	for(int i = 1;i <= 50000 / T;i++) res += 1ll * i * c[i * T];
	ans = ans + T * res * res * f[T];
    } printf("%lld\n",ans);
}
